package cn.kgc.controller;

import cn.kgc.entity.User;
import cn.kgc.entity.UserPage;
import cn.kgc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 郝雷蒙
 * @Description
 * @date 2020/12/25 9:04
 */
@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("all_users")
    public String getAllUsers(Integer pageNum, Integer pageSize, Model model){
        Integer page = pageNum==null? 1 : pageNum;
        Integer size = pageSize==null? 5 : pageSize;

        UserPage userPage = userService.getAllUsers(page,size);


        for (User user:userPage.getUserList()
             ) {
            System.out.println(user);
            
        }
        /**
         *
         */

        model.addAttribute("userPage",userPage);

        return "all_users";

    }
}
